﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EyFramework.AutoUpdate
{
    public class PublicGlobal
    {
        public static string UpdateUrl = "";
        public static string CurrentVersion = "";

        /// <summary>
        /// 启动参数封装成启动对象
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public static Entity.StartArgs GetStartUpArgs(string[] args)
        {
            Entity.StartArgs startUpArgs = null;
            if (args.Length > 0)
            {
                startUpArgs = new Entity.StartArgs();
                foreach (var arg in args)
                {
                    var argSplit = arg.Split(new Char[] { '=' });
                    if (argSplit.Length > 1)
                    {
                        if (argSplit[0].Trim().ToUpper() == "VERSION")
                        {
                            startUpArgs.Version = argSplit[1].Trim();
                        }
                        else if (argSplit[0].Trim().ToUpper() == "STARTCMD")
                        {
                            startUpArgs.StartCmd = argSplit[1].Trim();
                        }
                        else if (argSplit[0].Trim().ToUpper() == "PROCESSNAME")
                        {
                            startUpArgs.ProcessName = argSplit[1].Trim();
                        }
                    }
                }
            }
            else
            {
                startUpArgs = new Entity.StartArgs();
            }
            return startUpArgs;
        }
    }
}